package subraSoft.centaurus.model.util;

import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

/**
 * Simgleton para simplificar el acceso al sessionFactory a la base.
 * 
 * @author caeycae
 *
 */
public class CenHibernateUtil {

	private static CenHibernateUtil instance;
	private SessionFactory sessionFactory;
	
	/**
	 * Constructor privado (SINGLETON).
	 */
	private CenHibernateUtil()
	{
		sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
	}
	
	/**
	 * Obtiene la unica instancia del utilitario.
	 * 
	 * @return la unica instancia del utilitario.
	 */
	public static CenHibernateUtil getInstance()
	{
		if(instance == null)
			instance = new CenHibernateUtil();
		return instance;
	}

	/**
	 * Obtiene el sessionFactory.
	 * 
	 * @return el sessionFactory.
	 */
	public SessionFactory getSessionFactory()
	{
		return sessionFactory;
	}
}
